//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_targetsslbchange.sqf"
#include "xr_macros.sqf"

private ["_sel", "_ctrl", "_selIdx", "_data", "_unit"];
disableSerialization;
_sel = _this;
_ctrl = _sel select 0;
_selIdx = _sel select 1;
if (_selIdx == -1) exitWith {};
_data = lbData [1000, _selIdx];
if (_data == GVARXR(spectcamtargetstr)) exitWith {};
_unit = __getMNsVar2(_data);
if (isNil "_unit" || {isNull _unit}) exitWith {};
GVARXR(spectcamtargetstr) = _data;
_posunit = position _unit;
_posunit set [2, 2];
GVARXR(spectcamtarget) = _unit;
GVARXR(spectcam) camSetTarget GVARXR(spectcamtarget);
GVARXR(spectcam) camSetPos _posunit;
GVARXR(spectcam) cameraEffect ["INTERNAL", "Back"];
GVARXR(spectcam) camCommit 0;
ctrlSetText [1010, lbText [1000, _selIdx]];